<?php
/**
 * 获取用户已领取的卡券列表
 */
require_once('common.php');
$user_cardlist_url = 'https://api.weixin.qq.com/card/user/getcardlist?access_token='; //获取用户卡券列表的url

$access_token = get_access_token();
$card_id = $openid = '';
$openid = trim($_GET['openid']);
$card_id = trim($_GET['card_id']);
$openid = 'oEZwf1IRZc5a9EK-qK7kkUJLe5dw'; //wkk

/*----------------------获取用户的卡券列表 start---------------------*/
$postcardlistData = array(
    'openid' => $openid,
    'card_id'=> $card_id
);
$usercardlist = getusercardlist($user_cardlist_url.$access_token, $postcardlistData);
if($usercardlist['code'] != 0){
    echo_Json($usercardlist['code'], '获取用户卡券列表失败');
}else{
    echo_Json(0, '获取用户卡券列表成功', $usercardlist['card_list']);
}

function getusercardlist($url, $data){
    $cardlistArr = jsonpostJson($url, $data, true);
    if($cardlistArr['errcode'] != 0){
        $result['code'] = $cardlistArr['errcode'];
    }else{
        $result['code'] = 0;
        $result['card_list'] = $cardlistArr['card_list'];
    }
    return $result;
}
/*----------------------获取用户的卡券列表 end---------------------*/